// 添加按钮点击动画效果
document.getElementById('submit-btn').addEventListener('click', function() {
    this.style.backgroundColor = '#003d80';
    this.style.transform = 'scale(0.95)';
    setTimeout(() => {
        this.style.backgroundColor = '#007bff';
        this.style.transform = 'scale(1)';
    }, 300);
});

document.addEventListener('DOMContentLoaded', function() {
    // 处理select的动效
    const selects = document.querySelectorAll('.form-group select');
    selects.forEach(select => {
        select.addEventListener('change', function() {
            this.style.borderColor = '#0056b3';
            setTimeout(() => {
                this.style.borderColor = '#007bff';
            }, 300);
        });
    });

    // 时间更新功能
    function updateTime() {
        const now = new Date();
        document.querySelector('.current-time').textContent = now.toLocaleTimeString();
    }
    updateTime();
    setInterval(updateTime, 1000);
});

// 动态显示当前时间和系统运行时间
function updateDateTime() {
    const now = new Date();
    const currentTime = now.toLocaleString();
    document.getElementById('current-time').textContent = `当前时间: ${currentTime}`;
    
    // 假设系统启动时间为页面加载时间
    const startTime = new Date(document.documentElement.dataset.startTime);
    const runtime = Math.floor((now - startTime) / 1000);
    document.getElementById('system-runtime').textContent = `系统运行时间: ${runtime}秒`;
}

document.documentElement.dataset.startTime = new Date().toISOString();
setInterval(updateDateTime, 1000);
updateDateTime();

// 表单提交时处理多选兴趣
document.querySelector('form').addEventListener('submit', function(e) {
    const interestSelect = document.querySelector('#interest');
    const selectedOptions = Array.from(interestSelect.selectedOptions).map(opt => opt.value);
    const hiddenInput = document.createElement('input');
    hiddenInput.type = 'hidden';
    hiddenInput.name = 'interest[]';
    hiddenInput.value = selectedOptions.join(',');
    this.appendChild(hiddenInput);
});
